﻿namespace Emmajn.ChildParentExtension.BusinessApplication
{
    using System;
    using System.ComponentModel.DataAnnotations;
    using System.ServiceModel.DomainServices.Client;
    using System.ServiceModel.DomainServices.Client.ApplicationServices;
    using Emmajn.ChildParentExtension.BusinessApplication.Web.Resources;

    public enum VisitAvailability
    {
        None,
        One,
        Two,
        Three,
        Four
    }

    /// <summary>
    /// This internal entity is used to ease the binding between the UI controls
    /// (DataForm and the label displaying a validation error) and the log on
    /// credentials entered by the user.
    /// </summary>
    public class VolunteerInfo : Entity
    {
        private string visitorFirstName;
        private string visitorMiddleInitial;
        private string visitorLastName;
        private string visitorSuffix;
        private string visitorNumber;
        private string firstLineOfHomeAddress;
        private string secondLineOfHomeAddress;
        private string homeCity;
        private string stateProvinceOrRegion;
        private string homePostalCode;
        private string homeCountry;
        private string homeTelephoneNumber;
        private string officeTelephoneNumber;
        private string faxTelephoneNumber;
        private string beeperNumber;
        private VisitAvailability[] morningVisitAvailibilities = new VisitAvailability[7];
        private VisitAvailability[] afternoonVisitAvailibilities = new VisitAvailability[7];

        /// <summary>
        /// Gets and sets the first name.
        /// </summary>
        [Required]
        [Display(Name = "Visitor first name")]
        [StringLength(15)]
        public string VisitorFirstName
        {
            get
            {
                return this.visitorFirstName;
            }

            set
            {
                if (this.visitorFirstName != value)
                {
                    this.ValidateProperty("VisitorFirstName", value);
                    this.visitorFirstName = value;
                    this.RaisePropertyChanged("VisitorFirstName");
                }
            }
        }

        /// <summary>
        /// Gets and sets the middle initial.
        /// </summary>
        [Display(Name = "Visitor middle initial")]
        [StringLength(1)]
        public string VisitorMiddleInitial
        {
            get
            {
                return this.visitorMiddleInitial;
            }

            set
            {
                if (this.visitorMiddleInitial != value)
                {
                    this.ValidateProperty("VisitorMiddleInitial", value);
                    this.visitorMiddleInitial = value;
                    this.RaisePropertyChanged("VisitorMiddleInitial");
                }
            }
        }

        /// <summary>
        /// Gets and sets the last name.
        /// </summary>
        [Required]
        [Display(Name = "Visitor last name")]
        [StringLength(15)]
        public string VisitorLastName
        {
            get
            {
                return this.visitorLastName;
            }

            set
            {
                if (this.visitorLastName != value)
                {
                    this.ValidateProperty("VisitorLastName", value);
                    this.visitorLastName = value;
                    this.RaisePropertyChanged("VisitorLastName");
                }
            }
        }

        /// <summary>
        /// Gets and sets the suffix.
        /// </summary>
        [Display(Name = "Visitor suffix")]
        [StringLength(5)]
        public string VisitorSuffix
        {
            get
            {
                return this.visitorSuffix;
            }

            set
            {
                if (this.visitorSuffix != value)
                {
                    this.ValidateProperty("VisitorSuffix", value);
                    this.visitorSuffix = value;
                    this.RaisePropertyChanged("VisitorSuffix");
                }
            }
        }

        /// <summary>
        /// Gets and sets the number.
        /// </summary>
        [Required]
        [RegularExpression(@"^\d{3}-\d{2}-\d{4}$")]
        [Display(Name="Visitor number", Description = "NNN-NN-NNNN")]
        public string VisitorNumber
        {
            get
            {
                return this.visitorNumber;
            }

            set
            {
                if (this.visitorNumber != value)
                {
                    this.ValidateProperty("VisitorNumber", value);
                    this.visitorNumber = value;
                    this.RaisePropertyChanged("VisitorNumber");
                }
            }
        }


        [Display(Name = "First line of home address")]
        [Required]
        [StringLength(25)]
        public string FirstLineOfHomeAddress
        {
            get
            {
                return this.firstLineOfHomeAddress;
            }

            set
            {
                if (this.firstLineOfHomeAddress != value)
                {
                    this.ValidateProperty("FirstLineOfHomeAddress", value);
                    this.firstLineOfHomeAddress = value;
                    this.RaisePropertyChanged("FirstLineOfHomeAddress");
                }
            }
        }

        [Display(Name = "Second line of home address")]
        [StringLength(25)]
        public string SecondLineOfHomeAddress
        {
            get
            {
                return this.secondLineOfHomeAddress;
            }

            set
            {
                if (this.secondLineOfHomeAddress != value)
                {
                    this.ValidateProperty("SecondLineOfHomeAddress", value);
                    this.secondLineOfHomeAddress = value;
                    this.RaisePropertyChanged("SecondLineOfHomeAddress");
                }
            }
        }

        [Display(Name = "Home city")]
        [Required]
        [StringLength(14)]
        public string HomeCity
        {
            get
            {
                return this.homeCity;
            }

            set
            {
                if (this.homeCity != value)
                {
                    this.ValidateProperty("HomeCity", value);
                    this.homeCity = value;
                    this.RaisePropertyChanged("HomeCity");
                }
            }
        }

        [Display(Name = "Home state, province, or region")]
        [Required]
        [StringLength(14)]
        public string StateProvinceOrRegion
        {
            get
            {
                return this.stateProvinceOrRegion;
            }

            set
            {
                if (this.stateProvinceOrRegion != value)
                {
                    this.ValidateProperty("StateProvinceOrRegion", value);
                    this.stateProvinceOrRegion = value;
                    this.RaisePropertyChanged("StateProvinceOrRegion");
                }
            }
        }

        [Display(Name = "Home postal code")]
        [StringLength(10)]
        [RegularExpression(@"^[\w\d-\s]*$")]
        public string HomePostalCode
        {
            get
            {
                return this.homePostalCode;
            }

            set
            {
                if (this.homePostalCode != value)
                {
                    this.ValidateProperty("HomePostalCode", value);
                    this.homePostalCode = value;
                    this.RaisePropertyChanged("HomePostalCode");
                }
            }
        }

        [Display(Name = "Home country")]
        [Required]
        [StringLength(20)]
        public string HomeCountry
        {
            get
            {
                return this.homeCountry;
            }

            set
            {
                if (this.homeCountry != value)
                {
                    this.ValidateProperty("HomeCountry", value);
                    this.homeCountry = value;
                    this.RaisePropertyChanged("HomeCountry");
                }
            }
        }

        [Display(Name = "Home telphone number")]
        [Required]
        [RegularExpression(@"^(\+(\d{0,3})-)?(\d{0,3})-(\d{0,4})-(\d{0,4})( Ext (\d{0,6}))?$")]
        public string HomeTelephoneNumber
        {
            get
            {
                return this.homeTelephoneNumber;
            }

            set
            {
                if (this.homeTelephoneNumber != value)
                {
                    this.ValidateProperty("HomeTelephoneNumber", value);
                    this.homeTelephoneNumber = value;
                    this.RaisePropertyChanged("HomeTelephoneNumber");
                }
            }
        }

        [Display(Name = "Office telphone number")]
        [RegularExpression(@"^(\+(\d{0,3})-)?(\d{0,3})-(\d{0,4})-(\d{0,4})( Ext (\d{0,6}))?$")]
        public string OfficeTelephoneNumber
        {
            get
            {
                return this.officeTelephoneNumber;
            }

            set
            {
                if (this.officeTelephoneNumber != value)
                {
                    this.ValidateProperty("OfficeTelephoneNumber", value);
                    this.officeTelephoneNumber = value;
                    this.RaisePropertyChanged("OfficeTelephoneNumber");
                }
            }
        }

        [Display(Name = "Fax telphone number")]
        [RegularExpression(@"^(\+(\d{0,3})-)?(\d{0,3})-(\d{0,4})-(\d{0,4})( Ext (\d{0,6}))?$")]
        public string FaxTelephoneNumber
        {
            get
            {
                return this.faxTelephoneNumber;
            }

            set
            {
                if (this.faxTelephoneNumber != value)
                {
                    this.ValidateProperty("FaxTelephoneNumber", value);
                    this.faxTelephoneNumber = value;
                    this.RaisePropertyChanged("FaxTelephoneNumber");
                }
            }
        }

        /// <summary>
        /// Gets and sets the suffix.
        /// </summary>
        [Display(Name = "Beeper number")]
        [RegularExpression(@"^(\d{4})$")]
        public string BeeperNumber
        {
            get
            {
                return this.beeperNumber;
            }

            set
            {
                if (this.beeperNumber != value)
                {
                    this.ValidateProperty("BeeperNumber", value);
                    this.beeperNumber = value;
                    this.RaisePropertyChanged("BeeperNumber");
                }
            }
        }

        /// <summary>
        /// Gets and sets the suffix.
        /// </summary>
        [Display(Name = "Maximum number of patient visits in the morning")]
        [Required]
        public VisitAvailability[] MorningVisitAvailibilities
        {
            get
            {
                return this.morningVisitAvailibilities;
            }

            set
            {
                if (this.morningVisitAvailibilities != value)
                {
                    this.ValidateProperty("MorningVisitAvailibilities", value);
                    this.morningVisitAvailibilities = value;
                    this.RaisePropertyChanged("MorningVisitAvailibilities");
                }
            }
        }

        /// <summary>
        /// Gets and sets the suffix.
        /// </summary>
        [Display(Name = "Maximum number of patient visits in the afteroon")]
        [Required]
        public VisitAvailability[] AfternoonVisitAvailibilities
        {
            get
            {
                return this.afternoonVisitAvailibilities;
            }

            set
            {
                if (this.afternoonVisitAvailibilities != value)
                {
                    this.ValidateProperty("AfternoonVisitAvailibilities", value);
                    this.afternoonVisitAvailibilities = value;
                    this.RaisePropertyChanged("AfternoonVisitAvailibilities");
                }
            }
        }

    }
}
